package org.dreamwork.seagragon.filesystem;

import org.dreamwork.seagragon.ReadOnlyEnumeration;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 基于文件系统的 ServletConfig 对象
 *
 * <p>使用文件系统构建 ServletConfig 对象
 *
 * <pre>Created by IntelliJ IDEA.
 * User: seth
 * Date: 2010-4-24
 * Time: 18:28:31</pre>
 */
public class FSServletConfig implements ServletConfig {
    private ServletContext context;
    private String servletName;
    private Map<String, String> map = new ConcurrentHashMap<String, String> ();

    public FSServletConfig (ServletContext context, String servletName) {
        this.context = context;
        this.servletName = servletName;
    }

    public String getServletName () {
        return servletName;
    }

    public ServletContext getServletContext () {
        return context;
    }

    public String getInitParameter (String s) {
        return map.get (s);
    }

    public Enumeration getInitParameterNames () {
        return new ReadOnlyEnumeration (map.keySet ());
    }

    public Map<String, String> getInitParameters () {
        return map;
    }
}
